package com.wn.controller;

import com.wn.domain.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * @author yellow Docter
 * @date 2022 -10-24
 * @desc
 */
@RestController
@RequestMapping("user")
@Slf4j
public class UserController {

    @PostMapping("save")
    public String  saveUser(@RequestBody User user){
        log.info("添加的user:{}",user);
        return "add success";
    }

    @DeleteMapping("{id}")
    public String   deleteUser(@PathVariable("id")Integer id){
        log.info("删除的user的id:{}",id);
        return "delete success";
    }

    @PutMapping("update")
    public String  updateUser(@RequestBody User user){
        log.info("修改的user:{}",user);
        return "updaste success";
    }

    @GetMapping("/{id}")
    public User  getUserById(@PathVariable("id")Integer id){

        User user = new User();
        user.setName("mayun");
        user.setAge(45);
        log.info("查询的user的id:{}",id);
        return user;
    }

}
